import MapvLayer from "../../src/layer/mapv/MapvLayer";
import * as mapv from "mapv";

/**
 * 添加MapvLayer
 * @param {} earth 
 */
export default function addMapvLayer(earth){

    console.log("addMapvLayer.....")

    var randomCount = 300;
    var data = [];
    while (randomCount--) {
        data.push({
            geometry: {
                type: 'Point',
                coordinates: [-125.8 + Math.random() * 50, 30.3 + Math.random() * 20]
            },
            count: 30 * Math.random()
        });
    }
    let dataSet = new mapv.DataSet(data);
    //let dataSet = undefined;

    let options = {
    fillStyle: 'rgba(255, 250, 50, 0.8)',
    globalCompositeOperation: "lighter",
    maxSize: 10,
    max: 30,
    shadowBlur: 30,
    shadowColor: 'rgba(255, 250, 50, 1)',
    draw: 'bubble',
    projection: 'EPSG:4326',
    methods: {
        click: function (event) {
            console.log(event)
        },
        mousemove: function (event) {
            if (event) {
                mapvLayer.setDefaultCursor('pointer', event)
            } else {
                mapvLayer.setDefaultCursor('default', event)
            }
        }
    }
    };

    let layer = new MapvLayer("mapv", options);
    layer.setDataset(dataSet);
    earth.addLayer(layer);
 
}